<template>
  <fieldset>
    <legend>商品详情页</legend>
    <h1 class="title">商品名称:{{ goods.title }}</h1>
    <h3>价格:{{ goods.price }}</h3>
    <h4>商品描述:{{ goods.desc }}</h4>
    <img width="300" :src="goods.pic" alt="" />
  </fieldset>
</template>
<script>
import { getGoodsList } from "@/api";
export default {
  props: ["id"],
  data() {
    return {
      goods: {},
    };
  },
  created() {
    // let {id}=this.$route.params;
    let id = this.id;
    getGoodsList(id)
      .then((res) => {
        this.goods = res;
      })
      .catch((err) => {
        alert("数据获取出错,错误信息：" + err.errormsg);
      });
  },
  mounted() {
    // console.log(this.$router);
    // console.log(this.$route);
  },
};
</script>
